package com.nbufe.controller;

import com.nbufe.domain.ResponseResult;
import com.nbufe.service.FileServie;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author LZH
 * @date 2023/4/2
 */
@CrossOrigin
@Api(tags = "文件模块接口")
@RestController
@RequestMapping("/file")
public class FileController {

    @Resource
    private FileServie fileServie;

    @ApiOperation("导出燃料燃烧为excel")
    @GetMapping("/exportExcel")
    public void exportExcel(String fileName, HttpServletResponse response) {
        fileServie.exportExcel(fileName, response);
    }

    @ApiOperation("导入燃料燃烧excel")
    @PostMapping("/importExcel")
    public ResponseResult importExcel(MultipartFile file) {
        return fileServie.importExcel(file);
    }

    @ApiOperation("导入电力热力为excel")
    @PostMapping("/importElectricHeatExcel")
    public ResponseResult importElectricHeatExcel(MultipartFile file) {
        return fileServie.importElectricHeatExcel(file);
    }

    @ApiOperation("导出电力热力为excel")
    @GetMapping("/exportElectricHeatExcel")
    public void exportElectricHeatExcel(String fileName, HttpServletResponse response) {
        fileServie.exportElectricHeatExcel(fileName, response);
    }

    @ApiOperation("导入工业生产为excel")
    @PostMapping("/importIndustoryProduceExcel")
    public ResponseResult importIndustoryProduceExcel(MultipartFile file) {
        return fileServie.importIndustoryProduceExcel(file);
    }

    @ApiOperation("导出工业生产为excel")
    @GetMapping("/exportIndustoryProduceExcel")
    public void exportIndustoryProduceExcel(String fileName, HttpServletResponse response) {
        fileServie.exportIndustoryProduceExcel(fileName, response);
    }

    @ApiOperation("导入固碳产品为excel")
    @PostMapping("/importFixCarbonExcel")
    public ResponseResult importFixCarbonExcel(MultipartFile file) {
        return fileServie.importFixCarbonExcel(file);
    }

    @ApiOperation("导出固碳产品为excel")
    @GetMapping("/exportFixCarbonExcel")
    public void exportFixCarbonExcel(String fileName, HttpServletResponse response) {
        fileServie.exportFixCarbonExcel(fileName, response);
    }
}
